<template>
	<view class="mainpadding beijingse" v-if="pageShow">
		<view class=" ffffff mainpadding">
			<!-- <view class="titletext zhonghei fonweight">肯德基</view> -->
			<view class="flexbetween"  v-for="item in dataAll.goods" :key="item.id">
				<image class="sptp margin_right"  :src="item.image_text"  mode=""></image>
				<view class="flexcolumnbet" style="width: 77%;height: 150rpx;">
					<view class="ershiba xiaohei yhxk">{{item.title}}</view>
					<view class="ershil xiaohui">x{{item.number}}</view>
					<view class="titletext xiaohong fonweight">¥{{item.actual_payment}}</view>
				</view>
			</view>
		</view>
		<view class="ffffff radius mainpadding margin_top">
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">合计</view>
				<view class="ershil xiaohui">￥{{dataAll.total_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">联盟积分抵扣</view>
				<view class="ershil xiaohui">￥{{dataAll.score_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">首单优惠</view>
				<view class="ershil xiaohui">￥{{dataAll.sdyh_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">优惠券</view>
				<view class="ershil xiaohui">￥{{dataAll.coupon_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">实际支付</view>
				<view class="ershil xiaohong">¥{{dataAll.pay_price}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">订单编号</view>
				<view class="ershil xiaohui">{{dataAll.order_no}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">下单时间</view>
				<view class="ershil xiaohui">{{dataAll.createtime_text}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="ershil zhonghei">支付方式</view>
				<view class="ershil xiaohui">{{dataAll.pay_type==10?"微信支付":"余额支付"}}</view>
			</view>
			<view class="margin_top" v-if="dataAll.remarks">
				<text class="ershil zhonghei">备注：</text>
				<text class="ershil xiaohui">{{dataAll.remarks}}</text>
			</view>
		</view>
		<view class="bigbtn margin_top" @click="hexiao">确认核销</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				hx_code:"2EB8S7F126",
				dataAll:{},
				pageShow:false,
				type:0,
				
			}
		},
		onLoad(options) {
			if(options.hx_code){
				this.hx_code = options.hx_code
				this.type=1
			}
			// #ifdef MP-WEIXIN
			let _this = this
			const url = decodeURIComponent(options.q) // 获取到二维码原始链接内容
			if (url.indexOf("?") != -1) {
				var str = url.substr(url.indexOf("?") + 1);
				var strs = str.split("&");
				let theRequest = {};
				for (var i = 0; i < strs.length; i++) {
					theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
				}
				_this.hx_code = options.hx_code ? options.hx_code : (theRequest.hx_code ? theRequest.hx_code :
					0);
			}
			// #endif
			
		},
		onShow() {
			this.getDetail()
		},
		methods: {
			getDetail(){
				httpRequest.request('/api/shopcl/orderDetail', 'GET', {
					hx_code: this.hx_code,
				}).then(res => {
					if(res.code==1){
						this.pageShow = true
						this.dataAll = res.data
					}else{
						httpRequest.toast(res.msg)
						setTimeout(()=>{
							if(this.type==1){
								uni.navigateBack(1)
							}else{
								uni.switchTab({
									url:"/pages/index"
								})
							}
						},1000)
					}
					
				})
			},
			hexiao(){
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				httpRequest.request('/api/shopcl/orderHx', 'GET', {
					order_id: this.dataAll.id,
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							if(this.type==1){
								uni.navigateBack(1)
							}else{
								uni.switchTab({
									url:"/pages/index"
								})
							}
						},1000)
					}
				})
			},
			
		}
	}
</script>

<style>
.sptp {
		width: 150rpx;
		height: 150rpx;
		min-width: 150rpx;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}
</style>
